import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Leet1705 {
    public static void main(String[] args) {
        Leet1705 l = new Leet1705();
        System.out.println(Arrays.toString(l.findLongestSubarray(new String[]{"0","v","51","E","k","H"})));
    }
    public String[] findLongestSubarray(String[] array) {
        Map<Integer,Integer> map = new HashMap<>();
        int count = 0,max = 0,maxl = 0;
        for (int i = 0; i < array.length; i++) {
            if (isNum(array[i])){
                count++;
            }else count--;
            if (count==0){
                max = i+1;
                maxl = 0;
                continue;
            }
            if (map.containsKey(count)){
                if (max<i-map.get(count)){
                    max = i-map.get(0);
                    maxl = map.get(0)+1;
                }
            }else map.put(count,i);
        }
        String[] strs = new String[max];
        System.arraycopy(array,maxl,strs,0,max);
        return strs;
    }
    boolean isNum(String str){
        char s = str.charAt(0);
        return s <= '9' && s >= '0';
    }
}
